from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep


# alert弹窗

driver = webdriver.Chrome()
driver.get('file:///D:/qq/alert.html')
sleep(1)
driver.maximize_window()
sleep(2)
driver.find_element(By.ID, 'button').click()
sleep(2)
# 关闭弹窗
alert = driver.switch_to.alert
alert.accept()
sleep(2)


